package cn.minhx.dtm.starter.core.transaction;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.transaction.support.TransactionSynchronization;

/**
 * 事务提交后处理器 用于在事务提交后执行特定逻辑
 *
 * @author min
 */
public class TransactionCommitHandler implements TransactionSynchronization {

	private static final Logger log = LoggerFactory.getLogger(TransactionCommitHandler.class);

	private final Runnable afterCommitTask;

	public TransactionCommitHandler(Runnable afterCommitTask) {
		this.afterCommitTask = afterCommitTask;
	}

	@Override
	public void afterCommit() {
		log.debug("事务提交后处理");
		afterCommitTask.run();
	}
}
